<template>
  <div>
    <el-button @click="reqGet">get请求</el-button>
    <el-button @click="reqPut">put请求</el-button>
    <el-button @click="reqPost">post请求</el-button>
    <el-button @click="reqDelete">delete请求</el-button>
    <el-button @click="reqShop">Shop请求</el-button>
  </div>
</template>
  
<script>
import axios from 'axios'
export default {
  data () {
    return {}
  },
  methods:{
    reqGet(){
      console.log('123')
      axios({
          url:'http://127.0.0.1:3000/goods/list',
          method:'get'
      }).then(res=>{
          console.log(res)
      })
    },
    reqPut(){
        axios({
          url:'http://127.0.0.1:3000/goods/update',
          method:'put',
          data:{
            userName:'admin',
            userId:'001'
          }
      }).then(res=>{
          console.log(res)
      })
    },
    reqPost(){
        axios({
          url:'http://127.0.0.1:3000/goods/add',
          method:'post'
      }).then(res=>{
          console.log(res)
      })
    },
    reqDelete(){
        axios({
          url:'http://127.0.0.1:3000/goods/delete',
          method:'delete',
          params:{
            name:'tom',
            age:'18'
          }
      }).then(res=>{
          console.log(res)
      })
    },
    reqShop(){
      axios({
        url:'http://127.0.0.1:3000/user/list',
        method:'get'
      }).then(res=>{
        console.log(res)
      })
    }
  }
}
</script>
